<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    function login() {
        $.ajax({
            url: '/user/login',
            type: 'post',
            dataType: 'text',
            data: {"username": $('#name').val(), "password": $('#password').val()},
            success: function (d) {
                if (d) {
                    window.location.href = 'show.html';
                } else {
                    window.location.href = 'index.html';
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status); // 200
                alert(textStatus); // parsererror
                alert(errorThrown); // SyntaxError: Unexpected end of input
            }
        })
    }
</script>
<body>
    <p> 请输入用户名和密码</p>
     <form>
         <table>
             <tr>
                 <td>用户名</td>
                 <td><input type="text" id="name" ></td>
             </tr>
             <tr>
                 <td>密 码</td>
                 <td><input type="password" id="password" ></td>
             </tr>
             <tr>
                 <td colspan="2">
                     <input type="button" οnclick="login()" value="登陆">
                </td>
             </tr>
         </table>
     </form>
</body>
</html>